<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:ui="http://java.sun.com/jsf/facelets"
	   xmlns:f="http://java.sun.com/jsf/core" 
      xmlns:h="http://java.sun.com/jsf/html" 
      xmlns:a4j="http://richfaces.org/a4j"
	   xmlns:rich="http://richfaces.org/rich" 
      xmlns:composite="http://java.sun.com/jsf/composite">

<!-- INTERFACE -->
<composite:interface>
	<composite:attribute name="campo" />
	<composite:attribute name="campos" />
	<composite:attribute name="formato" />
	<composite:attribute name="formatos" />
	<composite:attribute name="mapTipoCampoTela" />
	<composite:attribute name="mapTipoCampo" />
	<composite:attribute name="mapAlinhamento" />
	<composite:attribute name="mapFormatos" />
	<composite:attribute name="addCampo" method-signature="void action()"/>	
</composite:interface>

<!-- IMPLEMENTATION -->
<composite:implementation>
<rich:panel id="campoPanel" styleClass=".form" header="Registro de campos para o formato #{cc.attrs.formato}" headerClass="header" columnClasses="label, none">
	<h:panelGrid columns="3" columnClasses="titleCell">

<!-- 		<h:panelGroup><div style="text-align:right; width:90px;"><h:outputLabel value="Formatos:" /></div></h:panelGroup> -->
<!-- 		<h:selectOneMenu id="listadeformato" value="#{cc.attrs.campo.formato}" style=" width : 350px;"> -->
<!-- 			<f:selectItems value="#{cc.attrs.formatos}" /> -->
<!-- 		</h:selectOneMenu> -->
<!-- 		<h:message for="listadeformato" errorClass="invalid" /> -->

		<h:panelGroup><div style="text-align:right; width:90px;"><h:outputLabel value="Nome:" /></div></h:panelGroup>
		<h:inputText id="nome" value="#{cc.attrs.campo.nome}" style=" width : 400px;" />
		<h:message for="nome" errorClass="invalid" />

		<h:panelGroup><div style="text-align:right; width:90px;"><h:outputLabel value="Descricao:" /></div></h:panelGroup>
		<h:inputTextarea id="descricaoCampo" value="#{cc.attrs.campo.descricao}" rows="4" cols="80" />
		<rich:message for="descricaoCampo" errorClass="invalid" />
				
		<h:panelGroup><div style="text-align:right; width:90px;"><h:outputLabel value="NomeColuna:" /></div></h:panelGroup>
		<h:inputText id="nomeColuna" value="#{cc.attrs.campo.nomeColuna}" style=" width : 400px;" />
		<h:message for="nomeColuna" errorClass="invalid" />
	</h:panelGrid>
		
	<h:panelGrid columns="6"  >
		<h:panelGroup><div style="text-align:right; width:90px;"><h:outputLabel value="Tamanho:" /></div></h:panelGroup>
		<h:inputText id="tamanho" value="#{cc.attrs.campo.tamanho}" style=" width : 100px;" />
		<h:message for="tamanho" errorClass="invalid" />

		<h:outputLabel for="tipoCampo" value="Tipo Campo:" />
		<h:selectOneMenu id="tipoCampo" value="#{cc.attrs.campo.tipoCampo}" style=" width : 200px;">
			<f:selectItems value="#{cc.attrs.mapTipoCampo}" />
		</h:selectOneMenu>
		<h:message for="tipoCampo" errorClass="invalid" />

		<h:panelGroup><div style="text-align:right; width:90px;"><h:outputLabel value="Tipo Campo Tela:" /></div></h:panelGroup>
		<h:selectOneMenu id="tipoCampoTela" value="#{cc.attrs.campo.tipoCampoTela}" style=" width : 200px;">
			<f:selectItems value="#{cc.attrs.mapTipoCampoTela}" />
		</h:selectOneMenu>
		<h:message for="tipoCampoTela" errorClass="invalid" />

		<h:outputLabel for="mascara" value="Mascara:" />
		<h:inputText id="mascara" value="#{cc.attrs.campo.mascara}" style=" width : 100px;" />
		<h:message for="mascara" errorClass="invalid" />

		<h:panelGroup><div style="text-align:right; width:90px;"><h:outputLabel value="Formato:" /></div></h:panelGroup>
		<h:selectOneMenu id="formatoDoCampo" value="#{cc.attrs.campo.formatoDoCampo}" style=" width : 150px;">
			<f:selectItems value="#{cc.attrs.mapFormatos}" />
		</h:selectOneMenu>
		<h:message for="formatoDoCampo" errorClass="invalid" />

		<h:outputLabel for="alinhamento" value="Tipo Campo:" />
		<h:selectOneMenu id="alinhamento" value="#{cc.attrs.campo.alinhamento}" style=" width : 150px;">
			<f:selectItems value="#{cc.attrs.mapAlinhamento}" />
		</h:selectOneMenu>
		<h:message for="alinhamento" errorClass="invalid" />
	</h:panelGrid>				
		
	<h:panelGrid columns="3" columnClasses="titleCell">
		<h:panelGroup><div style="text-align:right; width:90px;"><h:outputLabel value="Valor:" /></div></h:panelGroup>
		<h:inputText id="valor" value="#{cc.attrs.campo.valor}" style=" width : 335px;" />
		<h:message for="valor" errorClass="invalid" />
	</h:panelGrid>

	<h:panelGrid columns="9" columnClasses="titleCell">
		<h:panelGroup><div style="text-align:right; width:90px;"><h:outputLabel value="Chave Primaria:" /></div></h:panelGroup>
		<h:selectBooleanCheckbox id="chavePrimaria" value="#{cc.attrs.campo.chavePrimaria}" style=" width : 30px;" />
		<h:message for="chavePrimaria" errorClass="invalid" />

		<h:outputLabel for="chaveEstrangeira" value="Chave Estrangeira:" />
		<h:selectBooleanCheckbox id="chaveEstrangeira" value="#{cc.attrs.campo.chaveEstrangeira}" style=" width : 30px;" />
		<h:message for="chaveEstrangeira" errorClass="invalid" />
	</h:panelGrid>

	<h:panelGrid columns="3" columnClasses="titleCell">
		<h:panelGroup><div style="text-align:right; width:90px;"><h:outputLabel value="Versao:" /></div></h:panelGroup>
		<h:inputText id="versaoCampo" value="#{cc.attrs.campo.versao}" style=" width : 335px;" />
		<h:message for="versaoCampo" errorClass="invalid" />

		<h:panelGroup><div style="text-align:right; width:90px;"><h:outputLabel value="Texto Livre:" /></div></h:panelGroup>
		<h:inputTextarea id="textoLivreCampo" value="#{cc.attrs.campo.textoLivre}" rows="4" cols="80" />
		<h:message for="textoLivreCampo" errorClass="invalid" />

		<h:panelGroup><div style="text-align:right; width:90px;"><h:outputLabel value="Regra:" /></div></h:panelGroup>
		<h:inputTextarea id="regra" value="#{cc.attrs.campo.regra}" rows="4" cols="80" />
		<h:message for="regra" errorClass="invalid" />

		<h:commandButton id="addCampo" action="#{cc.attrs.addCampo}" value="Adicionar campo" title="Clique para adicionar campo"/>
	</h:panelGrid>
</rich:panel>

<rich:collapsiblePanel id="listaCampos" header="Campos" headerClass="header" title="Click to expand/collapse">
   <h:panelGroup rendered="#{empty cc.attrs.campos}">
      <em>No registered campos.</em>
   </h:panelGroup>
   <rich:dataTable var="item" value="#{cc.attrs.campos}" rendered="#{not empty cc.attrs.campos}" style="width : 100%">
	   <rich:column>
	      <a4j:commandLink styleClass="no-decor" render="listaCampos" execute="@this" oncomplete="#{rich:component('campoPopup')}.show()"> View
	         <f:setPropertyActionListener target="#{cc.attrs.campo}" value="#{item}"/>
	      </a4j:commandLink>
	   </rich:column>
	   <rich:column>
	      <f:facet name="header">Formato</f:facet>	#{item.formato.formato}
	   </rich:column>
	   <rich:column>
	      <f:facet name="header">Name</f:facet>		#{item.nome}
	   </rich:column>
	   <rich:column>
	      <f:facet name="header">Tamanho</f:facet>	#{item.tamanho}
	   </rich:column>
	   <rich:column>
	      <f:facet name="header">Tipo</f:facet>		#{item.tipoCampo}
	   </rich:column>
	</rich:dataTable>
</rich:collapsiblePanel>
</composite:implementation>
</html>
